import zhCn from 'element-plus/es/locale/lang/zh-cn'
import en from 'element-plus/es/locale/lang/en'
import { useStorage } from '@vueuse/core'
import { LanguageEnum } from '@/enums/settings/locale.enum'
import { computed } from 'vue'

// const state = reactive({})

export function useAppStore() {
  // 语言
  const language = useStorage('lang', LanguageEnum.ZH_CN)

  const locale = computed(() => {
    if (language?.value == 'en') {
      return en
    } else {
      return zhCn
    }
  })

  /**
   * 切换语言
   *
   * @param val
   */
  function changeLanguage(val: string) {
    language.value = val
  }

  return {
    locale,
    changeLanguage,
  }
}
